package com.bj58.data.emailreports.sends;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.bj58.data.emailreports.controllers.PartnershipReportController;
import com.bj58.data.emailreports.model.EmailReportUser;
import com.bj58.data.emailreports.utils.DateUtil;

public class PartnerSend extends BaseSend{

	public static void main(String[] args) {
		PartnerSend partner  = new PartnerSend();
		PartnershipReportController  partnerController = new PartnershipReportController();
		String searchDate="";
		
		try {
			searchDate = DateUtil.getStringDate(DateUtil.getDateBefore(new Date(), 1),"yyyy-MM-dd");//查询日期（昨）
			if(null != args && args.length > 0){
				if(args.length != 1){
					System.out.println("params error");
					System.exit(0);
				}
				if(args[0].contains("-")){
					searchDate =args[0].trim();
				}
			}
			System.out.println(searchDate);
			//searchDate="2016-01-13";
			//合作方数据日报
			
			List<EmailReportUser> userListCpc = partner.getUsersBySendType(50);
			
			String contextCpc = partnerController.partnershipReport(searchDate);			
			partner.ReportSend(userListCpc, "合作方日报"+ searchDate, contextCpc, null);				
		} catch (Exception e) {
			e.printStackTrace();
			String errorinfo=e.getMessage();
			EmailReportUser myself=new EmailReportUser();
			myself.setEmail("guoxue@58.com;jiaolulin@58.com;yuruiyan@58ganji.com");
			List<EmailReportUser> myselfList = new ArrayList<EmailReportUser>();
			myselfList.add(myself);
			
			partner.ReportSend(myselfList,"合作方日报测试报错" + searchDate, errorinfo,null);	
		}
	}

}
